package edu.dk.manager;

import edu.dk.dao.GenericDAO;
import edu.dk.model.ResourceAssignmentRecord;
import edu.dk.model.Resource;

class ResourceManager<T extends GenericDAO> {

    private T dao;

    public T getDao() {
        return dao;
    }

    public void setDao(T dao) {
        this.dao = dao;
    }

    public void assign(Resource resource) {
        ResourceAssignmentRecord record = new ResourceAssignmentRecord();
        record.setResource(resource);
        resource.setRecord(record);
        dao.add(record);
    }

    public void release(Resource resource) {
        dao.delete(resource.getRecord());
        //resource.setRecord(null);
    }
}